package jp.sinya.temicontact.utils;

import android.content.Context;

import com.afollestad.materialdialogs.MaterialDialog;

public class DialogUtils {

    private static DialogUtils dialogHelp;

    private MaterialDialog loadDialog;

    public static DialogUtils get() {
        if (dialogHelp == null) {
            dialogHelp = new DialogUtils();
        }
        return dialogHelp;
    }


    /**
     * 显示加载对话框
     *
     * @param context
     * @param content
     */
    public void showLoadDialog(Context context, String content) {
        loadDialog = new MaterialDialog.Builder(context).content(content).progress(true, 0).cancelable(true).show();
    }

    public MaterialDialog showLoadDialog(Context context, String content, boolean cancel) {
        loadDialog = new MaterialDialog.Builder(context).content(content).progress(true, 0).cancelable(cancel).show();
        return loadDialog;
    }

    /**
     * 关闭加载对话框
     */
    public void closeLoadDialog() {
        if (loadDialog != null) {
            loadDialog.dismiss();
        }
    }
}